// pages/evpi/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    carInfo: {
      logoUrl: '../../car/fute.jpg',
      name: '长安福特-新福克斯',
      model: '2018款1.0T手动超能风尚型智行版'
    },
    provinces: ['沪', '苏', '黑', '辽', '浙', '赣', '湘', '晋', '豫', '云', '冀', '皖', '鲁', '新', '鄂', '桂', '甘', '蒙', '陕', '吉', '闽', '贵', '粤', '川', '青', '藏', '琼', '宁', '渝', '京', '津'],
    currentPce: '沪',
    isKeyboardShow: false,
    isTipShow: false,
    drivingPhoto: false,
    idPhoto: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  drivingPhotoSwitch(event) {
    this.data.drivingPhoto = !this.data.drivingPhoto;
    this.setData({
      drivingPhoto: this.data.drivingPhoto
    })
  },

  idPhotoSwitch(event) {
    this.data.idPhoto = !this.data.idPhoto;
    this.setData({
      idPhoto: this.data.idPhoto
    })
  },

  showKeyboard(event) {
    this.data.isKeyboardShow = !this.data.isKeyboardShow;
    this.setData({
      isKeyboardShow: this.data.isKeyboardShow 
    })
  },

  setcurrentPce(event) {
    let currentPce = event.target.dataset.pce;
    this.setData({
      currentPce: currentPce,
      isKeyboardShow: false
    })
  },

  showTip(event) {
    this.data.isTipShow = !this.data.isTipShow;
    this.setData({
      isTipShow: this.data.isTipShow
    })
  },

  uploadImage() {
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success(res) {
        // tempFilePath可以作为img标签的src属性显示图片
        // const tempFilePaths = res.tempFilePaths
        console.log(res.tempFilePaths);
      }
    })
  },

  save() {
    let num = getCurrentPages().length;
    let delta = (num >= 4) ? num : 1;
    wx.navigateBack({
      delta: delta
    })
  }
})